From: Chad Horohoe Date: Mon, 22 Sep 2008 20:22:10 +0000 (+0000) Subject: Add ForeignAPIRepo::canCacheThumbs() method. Cleaner interface and removes some code... X-Git-Tag: 1.31.0-rc.0~45135 X-Git-Url: http://git.cyclocoop.org/%28%5B%5E/404?a=commitdiff_plain;h=ff0e6be471419d827c019cb5783de5f4acd9b781;p=lhc%2Fweb%2Fwiklou.git Add ForeignAPIRepo::canCacheThumbs() method. Cleaner interface and removes some code duplication. --- diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 42bd7e10b8..336c928004 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -31,7 +31,7 @@ class ForeignAPIFile extends File { } function transform( $params, $flags = 0 ) { - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->canCacheThumbs() ) { $thumbUrl = $this->repo->getThumbUrlFromCache( $this->getName(), isset( $params['width'] ) ? $params['width'] : -1, @@ -110,7 +110,7 @@ class ForeignAPIFile extends File { */ function getThumbPath( $suffix = '' ) { $ret = null; - if ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ) { + if ( $this->repo->canCacheThumbs() ) { global $wgUploadDirectory; $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/'; if ( $suffix ) { diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index bd53686d12..4943ed3ee2 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -112,7 +112,6 @@ class ForeignAPIRepo extends FileRepo { function getThumbUrlFromCache( $name, $width, $height ) { global $wgMemc, $wgUploadPath, $wgServer, $wgUploadDirectory; -; $key = wfMemcKey( 'ForeignAPIRepo', 'ThumbUrl', $name ); if ( $thumbUrl = $wgMemc->get($key) ) { @@ -135,4 +134,12 @@ class ForeignAPIRepo extends FileRepo { return $localUrl; } } + + /** + * Are we locally caching the thumbnails? + * @return bool + */ + public function canCacheThumbs() { + return ( $this->repo->apiThumbCacheExpiry > 0 && $this->repo->apiThumbCacheDir ); + } }